<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">{{ $t('production.productionType') }}</label>
        <el-select v-model="query.productionType" filterable :placeholder="$t('common.selectPlaceholder')" clearable style="width: 185px;" class="filter-item">
          <el-option
            v-for="item in dict.production_type"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <label class="el-form-item-label">{{ $t('production.palletCode') }}</label>
        <el-input v-model="query.palletCode" clearable :placeholder="$t('common.palletCode')" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">{{ $t('production.workNum') }}</label>
        <el-input v-model="query.workNum" clearable :placeholder="$t('common.workNum')" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />

      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="productionType" :label="$t('production.productionType')">
          <template slot-scope="scope">
            {{ dict.label.production_type[scope.row.productionType] }}
          </template>
        </el-table-column>
        <el-table-column prop="palletCode" :label="$t('production.palletCode')" />
        <el-table-column prop="stationCode" :label="$t('production.stationCode')" />
        <el-table-column prop="layUpBy" :label="$t('production.layUpBy')" />
        <el-table-column prop="unbindingBy" :label="$t('production.unbindingBy')" />
        <el-table-column prop="workNum" :label="$t('production.workNum')" />
        <el-table-column prop="qty" :label="$t('production.qty')" />
        <el-table-column prop="material" :label="$t('production.material')" />
        <el-table-column prop="layUpName" :label="$t('production.layUpName')" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, productionType: null, palletCode: null, stationCode: null, layUpBy: null, unbindingBy: null, workNum: null, qty: null, material: null, layUpName: null, layUpStartTime: null, layUpFinishTime: null, unbindingStartTime: null, unbindingFinishTime: null, pressingStartTime: null, pressingFinishTime: null }
export default {
  name: 'ProductionInfo',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['production_type'],
  cruds() {
    return CRUD({
      title: '1', url: 'api/productionInfo', idField: 'id', sort: 'id,desc', crudMethod: {},
      optShow: {
        add: false,
        edit: false,
        del: false,
        download: true,
        reset: true
      }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'productionInfo:add'],
        edit: ['admin', 'productionInfo:edit'],
        del: ['admin', 'productionInfo:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'productionType', display_name: '生产类型' },
        { key: 'palletCode', display_name: '容器编码' },
        { key: 'workNum', display_name: '工程号' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
